package com.example.administrator.capital.base;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;

import com.example.administrator.capital.utils.LogUtils;
import com.lzy.okgo.OkGo;

import java.util.UUID;

import yokeyword.fragmentation_swipeback.SwipeBackFragment;

/**
 * Created by YoKeyword on 16/2/7.
 *除了tab以外所以fragment
 */
public  class BaseBackFragment extends SwipeBackFragment implements View.OnClickListener{
    final public static int REQUEST_CODE_ASK_CALL_PHONE = 123;
    protected BaseActivity mBaseActivity;
    private static final String TAG = "Fragmentation";
    protected Bundle mBundle;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBundle = getArguments();
        if (mBundle==null) {
            mBundle = new Bundle();
        }
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mBaseActivity = (BaseActivity) getActivity();
        initView(view);
        setListener();
        setData();
    }
    protected void initView(View view) {
    }
    protected void setListener() {
    }
    protected void setData() {
    }
    @Override
    public void onStop() {
        super.onStop();
        LogUtils.d("取消请求");
        OkGo.getInstance().cancelTag(this);
    }
    protected void showActivity(Class<? extends BaseActivity> activity) {
        Intent intent = new Intent(mBaseActivity, activity);
        startActivity(intent);
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setParallaxOffset(0.5f);
    }


    @SuppressLint("MissingPermission")
    private String getMyUUID(){
        final TelephonyManager tm = (TelephonyManager)getActivity().getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

        final String tmDevice, tmSerial, tmPhone, androidId;

        tmDevice = "" + tm.getDeviceId();

        tmSerial = "" + tm.getSimSerialNumber();

        androidId= "" + android.provider.Settings.Secure.getString(getActivity().getContentResolver(),

                android.provider.Settings.Secure.ANDROID_ID);

        UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());

        String uniqueId = deviceUuid.toString();

        Log.d("debug","uuid="+uniqueId);
        return uniqueId;
    }
    private String getMyUUID2(){

        UUID uuid = UUID.randomUUID();

        String uniqueId = uuid.toString();

        Log.d("debug","----->UUID"+uuid);

        return uniqueId;

    }
    @Override
    public void onClick(View view) {
    }
//    protected void initToolbarNav(Toolbar toolbar) {
//        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
//        toolbar.setNavigationOnClickListener(new_name View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                _mActivity.onBackPressed();
//            }
//        });
//    }
}
